package com.yunfeisoft.business.model;

import com.yunfeisoft.common.base.BaseModel;
import com.yunfeisoft.common.sql.record.TransientField;
import com.yunfeisoft.common.utils.DateUtils;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * ClassName: OutHospital
 * Description: 老人出院流转表
 *
 * @Author: Jackie liu
 * Date: 2020-01-13
 */
@Entity
@Table(name = "TT_OUT_HOSPITAL")
public class OutHospital extends BaseModel implements Serializable {

    /**
     * Field serialVersionUID: 序列号
     */
    private static final long serialVersionUID = 1L;

    /**
     * 老人ID
     */
    @Column
    private String elderId;

    /**
     * 离院日期
     */
    @Column
    private Date leaveDate;

    public String getLeaveDateStr() {
        if (leaveDate == null) {
            return null;
        }
        return DateUtils.dateToString(leaveDate);
    }

    /**
     * 离院原因
     */
    @Column
    private String reason;

    /**
     * 备注
     */
    @Column
    private String remark;

    /**
     * 状态
     */
    @Column
    private Integer status;

    @TransientField
    private String elderName;

    @TransientField
    private String sex;

    public String getSexStr() {
        if ("1".equals(sex)) {
            return "男";
        }
        if ("2".equals(sex)) {
            return "女";
        }
        if ("3".equals(sex)) {
            return "未知";
        }
        return null;
    }

    @TransientField
    private String birthDate;

    @TransientField
    private String idcard;

    @TransientField
    private String code;

    @TransientField
    private String bedNum;

    @TransientField
    private Date checkInDate;

    @TransientField
    private Integer nursingLevel;

    @TransientField
    private Integer approvalStatus;

    public String getApprovalStatusStr() {
        if (approvalStatus == null) {
            return null;
        }
        return ElderApprovalResult.ApprovalStatusEnum.valueOf(approvalStatus);
    }
    @TransientField
    private Date approvalTime;

    public String getApprovalTimeStr() {
        if (approvalTime == null) {
            return null;
        }
        return DateUtils.dateToString(approvalTime);
    }

    public Integer getApprovalStatus() {
        return approvalStatus;
    }

    public void setApprovalStatus(Integer approvalStatus) {
        this.approvalStatus = approvalStatus;
    }

    public Date getApprovalTime() {
        return approvalTime;
    }

    public void setApprovalTime(Date approvalTime) {
        this.approvalTime = approvalTime;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(String birthDate) {
        this.birthDate = birthDate;
    }

    public String getIdcard() {
        return idcard;
    }

    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getBedNum() {
        return bedNum;
    }

    public void setBedNum(String bedNum) {
        this.bedNum = bedNum;
    }

    public Date getCheckInDate() {
        return checkInDate;
    }

    public String getCheckInDateStr() {
        if (checkInDate != null) {
            return DateUtils.dateToString(checkInDate);
        }
        return null;
    }

    public void setCheckInDate(Date checkInDate) {
        this.checkInDate = checkInDate;
    }

    public Integer getNursingLevel() {
        return nursingLevel;
    }

    public void setNursingLevel(Integer nursingLevel) {
        this.nursingLevel = nursingLevel;
    }

    public String getElderName() {
        return elderName;
    }

    public void setElderName(String elderName) {
        this.elderName = elderName;
    }

    public String getElderId() {
        return elderId;
    }

    public void setElderId(String elderId) {
        this.elderId = elderId;
    }

    public Date getLeaveDate() {
        return leaveDate;
    }

    public void setLeaveDate(Date leaveDate) {
        this.leaveDate = leaveDate;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public enum OutHospitalStatusEnum {
        REGISTER(1, "出院登记"),
        DOCTOR_ACCEPT(2, "医生评估通过"),
        DOCTOR_REJECT(3, "医生评估驳回"),
        NURSE_ACCEPT(4, "护理评估通过"),
        NURSE_REJECT(5, "护理评估通过"),
        LOGISTICS_ACCEPT(6, "后勤评估通过"),
        LOGISTICS_REJECT(7, "后勤评估驳回"),
        CONTRACT_ACCEPT(8, "院办签订协议通过"),
        CONTRACT_REJECT(9, "院办签订协议驳回"),
        HOSPITAL_OFFICE_ARCHIVE(10, "院办存档"),
        FINANCIAL_SETTLEMENT(11, "财务结算");

        private int value;
        private String label;

        private OutHospitalStatusEnum(int value, String label) {
            this.value = value;
            this.label = label;
        }

        public static String valueOf(Integer value) {
            if (value == null) {
                return null;
            }
            OutHospital.OutHospitalStatusEnum[] values = OutHospital.OutHospitalStatusEnum.values();
            for (OutHospital.OutHospitalStatusEnum loop : values) {
                if (value == loop.getValue()) {
                    return loop.getLabel();
                }
            }
            return null;
        }

        public Integer getValue() {
            return value;
        }

        public String getLabel() {
            return label;
        }
    }

    public String getStatusStr() {
        return OutHospital.OutHospitalStatusEnum.valueOf(status);
    }

    public String getNursingLevelStr() {
        if (nursingLevel == null) {
            return null;
        }
        return Elder.ElderNursingLevelEnum.valueOf(Integer.valueOf(nursingLevel));
    }


}